package com.loop.practice;

import java.util.HashSet;

public class PersonTest {
    public static void main(String[] args) {
        /**
         * 重写过HashCode和equals方法的Person类
         */
        Person p1= new Person("a",10);
        Person p2= new Person("a",10);
        System.out.println(p1==p2);
        HashSet<Person> set1 = new HashSet<>();
        set1.add(p1);
        set1.add(p2);
        System.out.println(set1);

        /**
         * 未重写过HashCode和equals方法的Person1类
         */
        Person1 p3= new Person1("a",10);
        Person1 p4= new Person1("a",10);
        HashSet<Person1> set = new HashSet<>();
        set.add(p3);
        set.add(p4);
        System.out.println(set);


    }
}
